/**
 * Formulario para Alterar Preferencias de Configuracao
 *
 * @this {UIPreferencesDialog}
 * @version
 */

function UIPreferencesDialog() {

    /**
     * Variaveis
     */
    var _oPreferencesDialog = null;
    var _autoSaveInterval = EGeneralTypes.eAutoSaveIntervalDefault;

    /**
     * Inicializa o objeto da classe
     */
    this.init = function() {

        // Dialog Preferencias
        this.initPreferencesDialog();
    }

    /**
     * Funcoes
     */
    this.initPreferencesDialog = function() {

        _oPreferencesDialog = new YAHOO.widget.Dialog("preferencesdialog", {
            constraintoviewport : true,
            fixedcenter : true,
            modal: false
        });
        var handleSubmit = function() {
            //valida intervalo de tempo fornecido
            var validator = new Validator();
            var htmlInput = document.getElementById('autosaveinterval');
            _autoSaveInterval = validator.integerNumber(htmlInput.value, _autoSaveInterval);
            htmlInput.value = _autoSaveInterval;
            //atualiza o intervalo de gravacao automatica do projeto
            var oLayoutProject = ModelInstance.getLayoutProject();
            oLayoutProject.autoSave(document.getElementById('autosave').checked, _autoSaveInterval);
            _oPreferencesDialog.hide();
        };
        var myButtons = [
        {
            text:"Aplicar",
            name:"preferencesbutton",
            handler:handleSubmit,
            isDefault:true
        }];
        _oPreferencesDialog.cfg.queueProperty("buttons", myButtons);
    }

    this.showPreferencesDialog = function() {
        _oPreferencesDialog.render();
        _oPreferencesDialog.show();
    }

    /**
     * Chamada do inicializador da classe
     */
    this.init();
}

